package com.wbl.train.common.business.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;

import java.time.LocalTime;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Pattern;
import lombok.Data;
import lombok.experimental.Accessors;

/**
 * @author 王博纶
 * @since 2024-02-01
 * @description 车次
 */
@Data
@Accessors(chain = true)
@TableName("train")
@Schema(name = "Train 对象", description = "车次 实体类")
public class TrainEntity{

    @Schema(description = "id")
    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(value = "id", type = IdType.ASSIGN_ID)
    private Long id;

    @Schema(description = "车次编号")
    @NotNull(message = "[车次编号不能为空]")
    private String code;

    @Schema(description = "车次类型|枚举[TrainTypeEnum]")
    @NotNull(message = "[车次类型不能为空]")
    private String type;

    @Schema(description = "始发站")
    @NotNull(message = "[站名不能为空]")
    @Pattern(regexp = "^[\\u4e00-\\u9fa5]+$",message = "[站名必须为汉字,且不能有空格]")
    private String start;

    @Schema(description = "始发站拼音")
    @Pattern(regexp = "^[a-z]+$",message = "[始发站拼音必须为小写字母]")
    private String startPinyin;

    @Schema(description = "出发时间")
    @NotNull(message = "[出发时间不能为空]")
    @JsonFormat(pattern = "HH:mm:ss",timezone = "GMT+8")
    private LocalTime startTime;

    @Schema(description = "终点站")
    @NotNull(message = "[终点站不能为空]")
    @Pattern(regexp = "^[\\u4e00-\\u9fa5]+$",message = "[站名必须为汉字,且不能有空格]")
    private String end;

    @Schema(description = "终点站拼音")
    @Pattern(regexp = "^[a-z]+$",message = "[终点站拼音必须为小写字母]")
    private String endPinyin;

    @Schema(description = "到站时间")
    @NotNull(message = "[到站时间不能为空]")
    @JsonFormat(pattern = "HH:mm:ss",timezone = "GMT+8")
    private LocalTime endTime;

    @Schema(description = "新增时间")
    private Date createTime;

    @Schema(description = "修改时间")
    private Date updateTime;


}
